<?php

define('IN',1);

require_once 'common.inc.php';

verify();

function verify() {
    $length = 4;
    $w = 48;
    $h = 25;
    $randcode = '';
    $text = '234678abcdefghjkmnprtuvwxyzABCDEFGHJKLMNPRTUVWXYZ';
    
    srand((double)microtime()*1000000);
    
    $im = imagecreate($w,$h);
    
    $bgColor = imagecolorallocate($im,255,255,255);
    imagefill($im,0,0,$bgColor);
    
    for ($i=0;$i<$length;$i++) {
        $code = substr($text,mt_rand(0,48),1);
        $j = !$i ? rand(0,4) : $j+rand(8,11);
        imagestring($im,4,$j,rand(1,11),$code,imagecolorallocate($im,mt_rand(0,100),mt_rand(0,100),mt_rand(0,100)));
        $randcode .= $code;
    }

    $_SESSION['verifycode'] = md5(strtolower($randcode));
    //但到底
    //干扰
    # 画弧
    //for ($i=0;$i<1;$i++) {
        //imagearc($im,mt_rand(-5,$w),mt_rand(-5,$h),mt_rand(20,300),mt_rand(20,200),55,44,imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)));
    //}导入
    #点
    for ($i=0,$j=$length*25;$i<$j;$i++) {
        imagesetpixel($im,mt_rand(0,$w),mt_rand(0,$h),imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)));
    }
    
    header("Content-type: image/gif");
    imagegif($im);
    imagedestroy($im);
}